/*
 * =====================================================================================
 *
 *       Filename:  constructor.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  05/17/2011 10:15:46 AM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  YOUR NAME (), 
 *        Company:  
 *
 * =====================================================================================
 */



#include <iostream>
#include <string>
using namespace std;
#include "gtest/gtest.h"
#include "List02.hpp"

TEST(ListTest, defaultConstructor)
{
	List<int> int_list;
	List<string> string_list;
	List<double> double_list;

	EXPECT_EQ(int_list.size(), 0u);
	EXPECT_EQ(string_list.size(), 0u);
	EXPECT_EQ(double_list.size(), 0u);
	
	EXPECT_TRUE(int_list.begin() == int_list.end() );
	EXPECT_TRUE(string_list.begin() == string_list.end() );
	EXPECT_TRUE(double_list.begin() == double_list.end() );


}

TEST(ListTest, repetitiveSequenceConstrutor)
{
	List<int> int_list(10u, 100);

	EXPECT_EQ(int_list.size(), 10u);
	EXPECT_TRUE(int_list.begin() != int_list.end());

	size_t cnt = 0;
	List<int>::iterator it;
	for(it = int_list.begin(); it != int_list.end(); ++it)
	{
		EXPECT_EQ(*it, 100);	
		++cnt;
	}
	EXPECT_EQ(int_list.size(), cnt);
}

TEST(ListTest, inputIteratorConstructor)
{
	int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
	List<int> int_list(arr, arr + sizeof(arr) / sizeof(int) );
	
	EXPECT_EQ(int_list.size(), sizeof(arr) / sizeof(int));
	EXPECT_TRUE(int_list.begin() != int_list.end());

	int cnt = 1;
	for (List<int>::iterator it = int_list.begin();
		it != int_list.end(); ++it)
	{
		EXPECT_EQ(*it, cnt++);
	}
}


TEST(ListTest, copyConstructor)
{
	int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
	List<int> int_list(arr, arr + sizeof(arr) / sizeof(int) );
	List<int> int_list2(int_list);

	EXPECT_EQ(int_list.size(), int_list2.size());
	List<int>::iterator it = int_list.begin();
	List<int>::iterator it2 = int_list2.begin();
	for (; it != int_list.end(); )
		EXPECT_EQ(*it++, *it2++);
}

